#include <iostream>
#include <vector>
#include <numeric>
#include <map>

using namespace std;

void go() {
	int n;
	cin >> n;
	vector<int> b(n);
	map<int, int> counts;
	map<int, vector<int>> groups;
	
	for (int i = 0; i < n; i++) {
		cin >> b[i];
		counts[b[i]]++;
		groups[b[i]].push_back(i);
	}
	
	for (auto const& [val, count] : counts) {
		if (count % val != 0) {
			cout << -1 << endl;
			return ;
		}
	}
	
	vector<int> a(n);
	int cur = 1;
	
	for (auto const& [val, list] : groups) {
		for (size_t i = 0; i < list.size(); i++) {
			if (i > 0 && i % val == 0) {
				cur++;
			}
			a[list[i]] = cur;
		}
		cur++;
	}
	
	for (int i = 0; i < n; i++) {
		cout << a[i] << (i == n - 1 ? "" : " ");
	}
	cout << endl;
	
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	cin >> t;
	while (t-- > 0) {
		go();
	}
	return 0;
}
